home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 633 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  67 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: Alexander Krotoff <krotoff@boy.nmd.msu.ru>
  3. Newsgroups: comp.std.c++
  4. Subject: Inialization and user-defined conversion
  5. Date: 05 Mar 1996 09:45:02 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <199603051249.PAA00513@boy.nmd.msu.ru>
  9. Reply-To: krotoff@such.srcc.msu.su
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. Content-Type: text
  12. X-Original-Date: Tue, 5 Mar 1996 15:49:34 +0300 (GMT+0300)
  13. X-Mailer: ELM [version 2.4 PL24]
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBVAwUBMTx9wUy4NqrwXLNJAQHF/QH/dpU3si7TyYKDLtpmNwoHnsmM6gAKstiT
  16.     rZAqWGERym/3bbtz7u8wj8nWLNk1j0MsvDJsQb74lQOKpW86eenCFQ==
  17.     =PJU/
  18. Originator: austern@isolde.mti.sgi.com
  19.  
  20. Hello c++ gurus,
  21.  
  22. I have a confusion with initialization of class objects.
  23. Example:
  24.  
  25. class C {
  26.  public:
  27.     C(int i);
  28. };
  29.  
  30. class D {
  31.  public:
  32.     D(C c);
  33. };
  34.  
  35. D d = 1;
  36.  
  37. void f()
  38. {
  39.     D d = 1;
  40. }
  41.  
  42. I assume, that both initializations are wrong, since they require sequence
  43. of two user-defined conversions. But some compilers disaggre ;-)
  44.  
  45. Boralnd c++ 4.0:    cannot convert "int" to "D"
  46. g++ 2.7.2:        no matching funcion for call to "D::D(int)"
  47. MS VC 4.0:        no errors
  48. Watcom 10.0:        no errors
  49.  
  50. As seems to me only Borland gives adequate diagnostics.
  51.  
  52. Who is right ? 
  53.  
  54. Thank you in advance,
  55.  
  56. --
  57. Alexander N. Krotoff        krotoff@such.srcc.msu.su
  58. Research Computer Center    tel: +7(095)939-2638
  59. Moscow State University        fax: +7(095)939-4430
  60. ---
  61. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  62.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  63.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  64.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  65.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  66. ]
  67.